package com.syj.collect.utils;

import android.icu.text.SimpleDateFormat;
import android.os.Build;

import androidx.annotation.RequiresApi;

import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Calendar;
import java.util.Date;

public  class DataUtils {

    @RequiresApi(api = Build.VERSION_CODES.N)
    public static String GetDateone() {
        String re_StrTime = null;
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyy-MM-dd HH:mm:ss");//HH时mm分ss秒
        // 例如：
        long lcc_time = Long.valueOf(System.currentTimeMillis());
        re_StrTime = sdf.format(new Date(lcc_time));
        return re_StrTime;
    }
    @RequiresApi(api = Build.VERSION_CODES.N)
    public static String getPastDate(int past) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
        Date today = calendar.getTime();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String result = format.format(today);
        return result;
    }

}
